<template>
  <a-card :bordered='false'>
    <!-- 查询区域 -->
    <div class='table-page-search-wrapper'>
      <a-form layout='inline' @keyup.enter.native='searchQuery'>
        <a-row :gutter='24'>
          <a-col :xl='24' :lg='7' :md='8' :sm='24'>
            <a-radio-group v-model='queryParam.todoStatus' @change='radioChange'>
              <a-form-item label='确认状态'>
                <a-radio :value='0'>未确认</a-radio>
                <a-radio :value='1'>全部</a-radio>
              </a-form-item>
            </a-radio-group>
          </a-col>
        </a-row>
        <a-row :gutter='24'>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='会议名称'>
              <a-input placeholder='请输入会议名称' v-model='queryParam.meetingName'></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='代办状态'>
              <j-dict-select-tag placeholder='请选择代办状态' v-model='queryParam.meetingStatus'
                                 dictCode='meeting_status' />
            </a-form-item>
          </a-col>
          <template v-if='toggleSearchStatus'>
            <a-col :xl='6' :lg='7' :md='8' :sm='24'>
              <a-form-item label='责任人'>
                <a-input placeholder='请输入责任人' v-model='queryParam.dealPersion'></a-input>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
              <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
              <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
              <a @click='handleToggleSearch' style='margin-left: 8px'>
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- 操作按钮区域 -->
    <!-- 高级查询区域 -->
    <!-- table区域-begin -->
    <div>
      <div class='ant-alert ant-alert-info' style='margin-bottom: 16px;'>
        <i class='anticon anticon-info-circle ant-alert-icon'></i> 已选择 <a style='font-weight: 600'>{{
          selectedRowKeys.length }}</a>项
        <a style='margin-left: 24px' @click='onClearSelected'>清空</a>
      </div>

      <a-table
        ref='table'
        size='middle'
        bordered
        rowKey='id'
        class='j-table-force-nowrap'
        :scroll='{x:true}'
        :columns='columns'
        :dataSource='dataSource'
        :pagination='ipagination'
        :loading='loading'
        :rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}'
        @change='handleTableChange'>

        <template slot='meetingName' slot-scope='text, record'>
          <a @click='handleDetail(record)'>{{ text }}</a>
        </template>
        <template slot='htmlSlot' slot-scope='text'>
          <div v-html='text'></div>
        </template>
        <template slot='imgSlot' slot-scope='text'>
          <span v-if='!text' style='font-size: 12px;font-style: italic;'>无图片</span>
          <img v-else :src='getImgView(text)' height='25px' alt=''
               style='max-width:80px;font-size: 12px;font-style: italic;' />
        </template>
        <template slot='fileSlot' slot-scope='text'>
          <span v-if='!text' style='font-size: 12px;font-style: italic;'>无文件</span>
          <a-button
            v-else
            :ghost='true'
            type='primary'
            icon='download'
            size='small'
            @click='downloadFile(text)'>
            下载
          </a-button>
        </template>
        <template slot='code' slot-scope='text, record'>
          <a @click='handleDetail(record)'>{{ text }}</a>
        </template>
        <template slot='todoDes' slot-scope='text, record'>
          <j-ellipsis :value='text' :length='50' />
        </template>
        <template slot='delayDays' slot-scope='text'>
          <span v-if='text == null || text ==0'>
            {{ text }}
          </span>
          <span v-else style='color: red'>
            {{ text }}
          </span>
        </template>

        <span slot='action' slot-scope='text, record'>
          <a @click='handleEdit(record)' v-if='!record.confirmPerson' v-has='"HfPmProjectMeetingTodoList:edit"'>确认</a>

          <a-divider type='vertical' v-if='!record.confirmPerson' />
          <a-dropdown>
            <a class='ant-dropdown-link'>更多 <a-icon type='down' /></a>
            <a-menu slot='overlay'>
              <a-menu-item>
               <a @click='handleDetail(record)'>详情</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <hf-pm-project-meeting-todo-modal ref='modalForm' @ok='modalFormOk' />
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import HfPmProjectMeetingTodoModal from '@views/hifar/meeting/modules/HfPmProjectMeetingTodoModal'
import store from '@/store'

export default {
  name: 'HfPmProjectMeetingTodoList',
  mixins: [JeecgListMixin],

  components: {
    HfPmProjectMeetingTodoModal
  },
  data() {
    return {
      description: '待办事项管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '代办编号',
          align: 'center',
          dataIndex: 'code',
          scopedSlots: { customRender: 'code' }


        },
        {
          title: '会议名称',
          align: 'center',
          dataIndex: 'meetingName'
        },
        {
          title: '代办内容',
          align: 'left',
          width: 600,
          dataIndex: 'todoDes',
          scopedSlots: { customRender: 'todoDes' }
        },
        {
          title: '责任人',
          align: 'center',
          dataIndex: 'dealPersion'
        },
        {
          title: '预计完成时间',
          align: 'center',
          dataIndex: 'playDealTime'
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'meetingStatus_dictText',
          customRender: function(text) {
            return !text ? '--' : text
          }
        },
        {
          title: '延期天数',
          align: 'center',
          dataIndex: 'delayDays',
          scopedSlots: { customRender: 'delayDays' }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/meeting/hfPmProjectMeetingRecords/todoList'
      },
      dictOptions: {},
      queryModel: true,
      queryParam: {
        todoStatus: 0
      }
    }
  },
  created() {
  },
  computed: {},
  methods: {
    handleEdit: function(record) {
      record.confirmPerson = store.getters.userInfo.username
      record.confirmTime = new Date()
      this.$refs.modalForm.edit(record)
      this.$refs.modalForm.title = '确认'
      this.$refs.modalForm.disableSubmit = false
    },
    searchReset() {
      this.queryParam = {}
      this.queryParam.todoStatus = 0
      this.loadData(1)
    },
    radioChange() {
      this.loadData()
    },
    initDictConfig() {
    }
  }
}
</script>

<style scoped>
@import '~@assets/less/common.less';
</style>